<%--
  Created by IntelliJ IDEA.
  User: Lai
  Date: 2021/10/5/0005
  Time: 9:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>js图片切换</title>
  </head>
  <body>
    <script>
        var time=1000;
        var curIndex=0;
        var arr=new Array();
        arr[0]="img/处暑.png";
        arr[1]="img/春分.png";
        arr[2]="img/白露.png";
        setInterval(changeImg,time);
        function changeImg(){
          var obj=document.getElementById("obj");
          if(curIndex===arr.length-1){
            curIndex=0;
          }else {
            curIndex+=1;
          }
          obj.src = arr[curIndex];
        }
    </script>
  <img id="obj" src="img/处暑.png" border="0">
  </body>
</html>
